package com.thering;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;
import java.io.StringWriter;

/**
 * author: the_ring
 * date: 2022/5/19
 * function: Type Mapper
 */
public class TypeCountMapper extends Mapper<LongWritable, Text, Text, IntWritable> {
    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String movie = value.toString();
        String types = movie.split("\t")[4];
        for (String type : types.split("/")) {
            context.write(new Text(type), new IntWritable(1));
        }
    }
}
